"""
添加页面
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from page_objects.base_page import BasePage
from utils.log_util import logger
from utils.web_util import click_exception


class CategoryCreatePage(BasePage):
    __INPUT_GOODS_NUMBER = (By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[1]/div/form/div[1]/div/div[1]/input')
    __INPUT_GOODS_NAME = (By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[1]/div/form/div[2]/div/div[1]/input')
    __BTN_SUBMIT = (By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[5]/button[2]')

    def create_category(self):
        logger.info("商品上架页面：填写信息，上架")
        self.do_send_keys("1235678", self.__INPUT_GOODS_NUMBER)
        # self.driver.find_element(By.CSS_SELECTOR, ".el-input__inner").send_keys("新增商品测试")
        self.do_send_keys("新增商品测试444", self.__INPUT_GOODS_NAME)
        WebDriverWait(self.driver, 10).until(
            click_exception(*self.__BTN_SUBMIT)
        )
        # self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[5]/button[2]').click()
        self.do_find(self.__BTN_SUBMIT).click()
        from page_objects.category_list_page import CategoryListPage
        return CategoryListPage(self.driver)
